---
layout: "default"
title: "COpaquePointer"
description: "Swift documentation for 'COpaquePointer': A wrapper around an opaque C pointer."
keywords: "COpaquePointer,struct,swift,documentation,encode,debugDescription,hashValue"
root: "/v1.2"
---

<div class="intro-declaration"><code class="language-swift">struct COpaquePointer</code></div>

<div class="discussion comment">
    <p>A wrapper around an opaque C pointer.</p>

<p>Opaque pointers are used to represent C pointers to types that
cannot be represented in Swift, such as incomplete struct types.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">CVarArgType, DebugPrintable, Equatable, Hashable, NilLiteralConvertible</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>



<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init">
<a class="toggle-link" data-toggle="collapse" href="#comment-init">init()</a><div class="comment collapse" id="comment-init"><div class="p">
    <p>Construct a <code>nil</code> instance.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init()</code>

    </div></div>
</div>
<div class="declaration" id="init-t_-cfunctionpointer-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-t_-cfunctionpointer-t">init&lt;T&gt;(<wbr>_: CFunctionPointer&lt;T&gt;)</a><div class="comment collapse" id="comment-init-t_-cfunctionpointer-t"><div class="p">
    <p>Reinterpret the bits of <code>value</code> as <code>COpaquePointer</code>.</p>

<p><strong>Warning:</strong> This is a fundamentally unsafe operation, equivalent to
     <code>unsafeBitCast(value, COpaquePointer.self)</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;T&gt;(_ value: CFunctionPointer&lt;T&gt;)</code>

    </div></div>
</div>
<div class="declaration" id="init-t_-unsafemutablepointer-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-t_-unsafemutablepointer-t">init&lt;T&gt;(<wbr>_: UnsafeMutablePointer&lt;T&gt;)</a><div class="comment collapse" id="comment-init-t_-unsafemutablepointer-t"><div class="p">
    <p>Convert a typed <code>UnsafeMutablePointer</code> to an opaque C pointer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;T&gt;(_ source: UnsafeMutablePointer&lt;T&gt;)</code>

    </div></div>
</div>
<div class="declaration" id="init-t_-unsafepointer-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-t_-unsafepointer-t">init&lt;T&gt;(<wbr>_: UnsafePointer&lt;T&gt;)</a><div class="comment collapse" id="comment-init-t_-unsafepointer-t"><div class="p">
    <p>Convert a typed <code>UnsafePointer</code> to an opaque C pointer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;T&gt;(_ source: UnsafePointer&lt;T&gt;)</code>

    </div></div>
</div>
<div class="declaration" id="init-bitpattern_-uword">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-bitpattern_-uword">init(<wbr>bitPattern: UWord)</a><div class="comment collapse" id="comment-init-bitpattern_-uword"><div class="p">
    <p>Construct a <code>COpaquePointer</code> from a given address in memory.</p>

<p>This is a fundamentally unsafe conversion.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(bitPattern: UWord)</code>

    </div></div>
</div>
<div class="declaration" id="init-bitpattern_-word">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-bitpattern_-word">init(<wbr>bitPattern: Word)</a><div class="comment collapse" id="comment-init-bitpattern_-word"><div class="p">
    <p>Construct a <code>COpaquePointer</code> from a given address in memory.</p>

<p>This is a fundamentally unsafe conversion.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(bitPattern: Word)</code>

    </div></div>
</div>
<div class="declaration" id="init-nilliteral_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-nilliteral_">init(<wbr>nilLiteral:)</a><div class="comment collapse" id="comment-init-nilliteral_"><div class="p">
    <p>Create an instance initialized with <code>nil</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(nilLiteral: ())</code>

    </div></div>
</div>


<h3>Instance Variables</h3>
<div class="declaration" id="var-debugdescription_-string">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-debugdescription_-string">var debugDescription: String</a><div class="comment collapse" id="comment-var-debugdescription_-string"><div class="p">
    <p>A textual representation of <code>self</code>, suitable for debugging.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var debugDescription: String { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-hashvalue_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-hashvalue_-int">var hashValue: Int</a><div class="comment collapse" id="comment-var-hashvalue_-int"><div class="p">
    <p>The hash value.</p>

<p><strong>Axiom:</strong> <code>x == y</code> implies <code>x.hashValue == y.hashValue</code></p>

<p><strong>Note:</strong> the hash value is not guaranteed to be stable across
different invocations of the same program.  Do not persist the
hash value across program runs.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var hashValue: Int { get }</code>

    </div></div>
</div>



<h3>Instance Methods</h3>
<div class="declaration" id="func-encode">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-encode">func encode()</a>
        
<div class="comment collapse" id="comment-func-encode"><div class="p">
    <p>Transform <code>self</code> into a series of machine words that can be
appropriately interpreted by C varargs</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func encode() -&gt; [Word]</code>
    
    
</div></div>
</div>


